//
//	File Name   :	OpenGLVertexBuffer.cpp
//	Description :	OpenGLVertexBuffer implementation file.
//	Author		:	William McVicar
//  Mail		:	mcvicar.william@gmail.com
//

//  Precompiled Header
#include "CommonDefines.h"
#ifdef OPENGL

//  Library Includes

//  Local Includes
#include "VertexBufferBase.h"
#include <gl/GL.h>
#include "OpenGLExtensions.h"

//  This includes
#include "OpenGLVertexBuffer.h"

//	Macros

//  Static Variables

//  Static Function Prototypes

//  Implementation

namespace Protein
{

VertexBuffer::VertexBuffer(VertexBufferBase* _pBase )
{
	OpenGLExtensions::glGenBuffersARB( 1, &m_bufferID );
	OpenGLExtensions::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_bufferID );
	OpenGLExtensions::glBufferDataARB( GL_ARRAY_BUFFER_ARB, _pBase->NumBytes(), _pBase->Data(), GL_STATIC_DRAW_ARB );
	OpenGLExtensions::glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
}

VertexBuffer::~VertexBuffer()
{
	OpenGLExtensions::glDeleteBuffersARB( 1, &m_bufferID );
}

void VertexBuffer::Enable()
{
	OpenGLExtensions::glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_bufferID );
}

void VertexBuffer::Disable()
{
	OpenGLExtensions::glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
}

}

#endif